package
{
	import mx.containers.Grid;
	import mx.containers.GridItem;
	import mx.containers.GridRow;
	import mx.controls.Label;
	// 월요일 = 0 일요일 = 6 -> index 예를들어, add(5) 금요일일때 토요일일때 일요일 add하는 case 커버해주
	public class ScheduleTable extends Grid
	{
		private var days:Array = new Array("Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
		//private var satOn:Boolean = true;
		//private var sunOn:Boolean = false;
		//private var track:Number = 0;
		private var first:GridRow = new GridRow();
		private var clr1:int = 0xFF00FF;
		private var clr2:int = 0x000000;
		
		public function removCol(i:int):void
		{
			for each (var r:GridRow in this.getChildren())
				r.removeChildAt(i);
		}
		
		public function addCol(i:int):void
		{
			var day:GridItem = new GridItem();
			day.percentWidth = 100;
			day.percentHeight = 100;
			day.setStyle("backgroundColor", 0xF3D3D3);
			var daylabel:Label = new Label();
			
			daylabel.text=days[i];
			day.addChild(daylabel);
			first.addChild(day);
			
			for each (var r:GridRow in this.getChildren())
			{
				var index:int = this.getChildIndex(r);
				if (index != 0)
				{
					var c:GridItem = new GridItem();
					c.percentWidth=100;
					c.percentHeight=100;
					var clr:int = index%2==0 ? clr2 : clr1;
					c.setStyle("backgroundColor",clr);
					var label:Label = new Label();
					c.addChild(label);
					r.addChild(c);
				}
			}
		}
		
		protected override function createChildren():void
		{
			super.createChildren();

			
			first.percentWidth=100;
			first.percentHeight=100;
			
			for (var i:Number = 0; i < 5; i++)
			{
				var day:GridItem = new GridItem();
				
				day.percentWidth = 100;
				day.percentHeight = 100;
				day.setStyle("backgroundColor",0xF3D3D3);
				var daylabel:Label = new Label();
				
				daylabel.text=days[i];
				day.addChild(daylabel);
				first.addChild(day);
			}
			this.addChild(first);
			

			for (var y:Number = 0; y < 10; y++)
			{
				var r:GridRow = new GridRow();
				r.percentWidth=100;
				r.percentHeight=100;	

				for (var x:Number = 0; x < 5; x++)
				{
					var c:GridItem = new GridItem();
					c.percentWidth=100;
					c.percentHeight=100;
					c.setStyle("backgroundColor",(y%2==0?clr1:clr2));
					var label:Label = new Label();
					c.addChild(label);
					r.addChild(c);		
				}
				this.addChild(r);
			}
			addCol(5);
			addCol(6);
			//removCol(5);
		}
	}
}